/**
 * @author jprieur
 */
package mygui;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.KeyStroke;

import kernel.Simulator;


public class ActionPause extends AbstractAction 
{
    private MonIHM _ihm;

    public ActionPause(MonIHM ihm)
    {
	_ihm = ihm;

	putValue(AbstractAction.NAME,"Pause");
	putValue(AbstractAction.SHORT_DESCRIPTION,"Pause the simulation");
	putValue(AbstractAction.ACCELERATOR_KEY,KeyStroke.getKeyStroke(KeyEvent.VK_SPACE,KeyEvent.CTRL_MASK ));
	putValue(AbstractAction.SMALL_ICON,UIM.createImageIcon("images/pause.png","Pause"));
    }

    public void actionPerformed(ActionEvent arg) {
	if(_ihm._kernel.getState() == Simulator.PLAY){
	    _ihm._kernel.pauseSim();
	}
	_ihm.updateCommandes();
	_ihm._display.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }

}
